package Q3;

import java.util.Scanner;

public class Main {

    public static int n;

    public static boolean flag;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();

        while (t > 0) {
            t--;
            n = scanner.nextInt();
            String[] strs = new String[n];
            for (int i = 0; i < n; i++) {
                strs[i] = scanner.next();
            }

            dfs(strs, 0, new StringBuilder());

            if (flag) {
                System.out.println("Yes");
                flag = false;
            } else {
                System.out.println("No");
            }
        }
    }

    public static void dfs(String[] strs, int index, StringBuilder stringBuilder) {

        if (flag) {
            return;
        }

        if (index == n) {
            String str = stringBuilder.toString();
            int left = 0, right = n - 1;
            while (left < right) {
                if (str.charAt(left) != str.charAt(right)) {
                    return;
                }
                left++;
                right--;
            }

            flag = true;
            return;
        }

        for (int i = 0; i < strs[index].length(); i++) {
            stringBuilder.append(strs[index].charAt(i));
            dfs(strs, index + 1, stringBuilder);

            //回溯
            stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        }
    }
}
